package com.gitee.cashzhang.test.basic.thread;

import java.util.Timer;
import java.util.TimerTask;

/**
 * @author Cash Zhang
 * @version v1.0
 * @since 2019/05/09 10:57
 */
public class Thread4 {

  public static void main(String[] args) {
    Thread thread1 = new Thread(() -> {
      // TODO
    }, "thread");
    thread1.start();

    new Thread() {
      @Override
      public void run() {
        // TODO
      }
    }.start();

    new Thread(new Runnable() {
      @Override
      public void run() {
        // TODO
      }
    }).start();

    Timer timer = new Timer();
    timer.scheduleAtFixedRate((new TimerTask() {
      @Override
      public void run() {
        System.out.println("定时任务1执行了....");
      }
    }), 2000, 1000);
  }

}
